package cn.zh.service.impl;

import cn.zh.commons.ResponseResult;
import cn.zh.entity.LogInfoCopy;
import cn.zh.mapper.LogInfoMapper;
import cn.zh.service.LogInfoService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author : 张航
 * @date : 2024-05-30 15:10
 * @description:
 **/
@Service
public class LogInfoServiceImpl implements LogInfoService {
    @Resource
    private LogInfoMapper logInfoMapper;


    public ResponseResult logsPage(Integer page, Integer limit, String model, String description) {

        PageHelper.startPage(page,limit);
        List<LogInfoCopy> logInfos= logInfoMapper.searchLogs(model,description);
        PageInfo<LogInfoCopy> logInfoPageInfo = new PageInfo<LogInfoCopy>(logInfos);
        long total = logInfoPageInfo.getTotal();

        return ResponseResult.success().data(logInfos).count(total);
    }


    public ResponseResult deletelogs(Integer[] ids) {
        logInfoMapper.deletelogs(ids);
        return ResponseResult.success().message("删除成功");
    }


    public ResponseResult addLogInfo(LogInfoCopy logInfoCopy) {
        logInfoMapper.addLogInfo(logInfoCopy);
        return ResponseResult.success();
    }
}
